/**
 * Assignment 5            P5Cylinder.java                  Due July 20, 2011
 *
 * login: cs11ubn
 */

/**
 * Cylinder object that inherits Circle. Overrides the area, volume and
 * toString methods.
 */
public class P5Cylinder extends P5Circle
{
  protected double height; // Holds the height of the cylinder

  /**
   * No-arg ctor. Initialize height to 0 and call the no-arg super
   */
  public P5Cylinder()
  {
    super(); // No arg super class
    height = 0; // Set height to 0
  }

  /**
   * 2-arg ctor. Initialize to the given radius and height
   */
  public P5Cylinder(double r, double h)
  {
    super(r); // Make a circle with the given radius
    height = h; // Set height to given
  }

  /**
   * Override Circles volume method.
   */
  public double volume()
  {
    return (super.area()*height); // volume is circle area * height
  }

  /**
   * Override Circles area method.
   */
  public double area()
  {
    // Area is 2 times the circle area plus the area around it
    return ((2 * super.area()) + (2 * PI * rad * height));
  }

  /**
   * Override Circles toString method.
   */
  public String toString()
  {
    return ("Cylinder:\t" + rad + " x " + height); // Cylinder output
  }
}
